package com.xwtec.builder;

/**
 * @Author: zt
 * @Date: 2021/3/6 15:42
 * 构建一个超级复杂的对象，分批次构建
 */
public class Person {
    String id ;
    String name;
    int age;
    double weight;
    int score;
    Location location;

    private Person(){}

    public static class PersonBuilder{
        Person person = new Person();

        public PersonBuilder buildBasic(String id,String name,int age){
            person.id = id;
            person.name = name;
            person.age = age;
            return this;

        }
        public PersonBuilder buildWeight(double weight){
            person.weight = weight;
            return this;
        }
        public PersonBuilder buildScore(int score){
            person.score = score;
            return this;
        }
        public  PersonBuilder buildLocation(Location location){
            person.location =location;
            return this;
        }
        public Person build(){
            return person;
        }
    }

    @Override
    public String toString() {
        return "Person{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", weight=" + weight +
                ", score=" + score +
                ", location=" + location +
                '}';
    }
}
class Location{
    String Street;
    String door;

    public Location(String street, String door) {
        Street = street;
        this.door = door;
    }

    @Override
    public String toString() {
        return "Location{" +
                "Street='" + Street + '\'' +
                ", door='" + door + '\'' +
                '}';
    }
}
